package com.vanke.house.service;

import com.vanke.house.model.SaleHouse;
import com.vanke.house.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * Server酱 服务
 * @author fangyu
 * @version v1.0.0
 * @date 2020/6/22 4:00 下午
 */
@Service
public class FTQQService {

    @Autowired
    private RestTemplate restTemplate;

    public static final String SCKEY = "SCU67229T0956123fc11fb4074e0e6c9a893ccf2b5ddbe0a0b48f4";

    public String sendMessage(SaleHouse saleHouse){
        String content = "**" + saleHouse.getTitle() + "**\n" +
                "------\n" +
                "链接：" + saleHouse.getLink() + "\n" +
                "```\n" +
                "标签：" + saleHouse.getIsFullTwo() + "\n" +
                "单价：" + saleHouse.getUnitPrice() + "\n" +
                "挂牌价：" + saleHouse.getListingPrice() + "万\n" +
                "户型：" + saleHouse.getHouseType() + "\n" +
                "面积：" + saleHouse.getHouseArea() + "\n" +
                "朝向：" + saleHouse.getOrientation() + "\n" +
                "时间：" + DateUtils.newTime() + "\n" +
                "------\n";
        String url = "https://sc.ftqq.com/" + SCKEY + ".send?text=万科金色城市K3地块新房源上架通知:&desp=" + content;
        return restTemplate.getForObject(url, String.class);
    }
}
